package banking7.reports;
import  banking7.domain.*;

import java.text.NumberFormat;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:恋恋
 * Date:2022-11-03
 * Time:12:33
 */
public class CustomerReport {
    // 在前面的银行项目练习中，“客户报告”功能是在 TestBanking 应用程序的main 方法中实现的。
    // 在本练习中，修改代码把“客户报告”功能放在 banking.reports 包的CustomerReport 类中实现。您的任务是修改这个类，使其使用单一银行对象并格式化输出该银行的客户报告。
   public void generateReport(Bank bank){
       NumberFormat currency_format = NumberFormat.getCurrencyInstance();
       System.out.println("\t\t\tCUSTOMER REPORT");
       System.out.println("\t\t\t===============");
       for (int i = 0; i < bank.getNumberOfCustomer(); i++) {
           System.out.println("Customer:"+bank.getCustomer(i).getLastName()+","+bank.getCustomer(i).getFirstName());
           for (int j = 0; j < bank.getCustomer(i).getGetNumOfAccounts(); j++) {
               Account account=bank.getCustomer(i).getAccount(j);
               String account_type=null;
               if(account instanceof SavingsAccount){
                   account_type="Savings Account";

               }
               if(account instanceof CheckingAccount){
                   account_type="Checking Account";
               }
               System.out.println("\t"+account_type+":current balance is"+NumberFormat.getCurrencyInstance().format(bank.getCustomer(i).getAccount(j).getBalance()));
           }

       }
   }
}
